﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace HammerMUD.System
{
    public class Color
    {
        public static String Reset = "\\033[0m";
        public static String Bold = "[1m";
        public static String Italics = "[3m";
        public static String Underline = "[4m";
        public static String Inverse = "[7m";
        public static String StrikeThrough = "[9m";
        public static String BoldOff = "[22m";
        public static String ItalicsOff = "[23m";
        public static String UnderlineOff = "[24m";
        public static String InverseOff = "[27m";
        public static String StrikeThroughOff = "[29m";
        public static String Black = "[30m";
        public static String Red = "\\033[31m";
        public static String Green = "\033[32m";
        public static String Yellow = "[33m";
        public static String Blue = "[34m";
        public static String Magenta = "[35m";
        public static String Cyan = "[36m";
        public static String White = "[37m";
        public static String Default = "[39m";
        public static String BackgroundBlack = "[40m";
        public static String BackgroundRed = "[41m";
        public static String BackgroundGreen = "[42m";
        public static String BackgroundYellow = "[43m";
        public static String BackgroundBlue = "[44m";
        public static String BackgroundMagenta = "[45m";
        public static String BackgroundCyan = "[46m";
        public static String BackgroundWhite = "[47m";
        public static String BackgroundDefault = "[49m";
    }

    public class Colorizer
    {
        public static String AntiBleed = "\\033[0m";

        public static String InjectColors(String stringToInject)
        {
            //stringToInject = Regex.Replace(stringToInject, @"^color\(\)", "$1" + Color.Reset);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\(\)", "$1" + Color.Reset);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((Bold)\)", "$1" + Color.Bold);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((Bold)\)", "$1" + Color.Bold);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((Italics)\)", "$1" + Color.Italics);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((Italics)\)", "$1" + Color.Italics);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((Underline)\)", "$1" + Color.Underline);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((Underline)\)", "$1" + Color.Underline);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((Inverse)\)", "$1" + Color.Inverse);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((Inverse)\)", "$1" + Color.Inverse);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((StrikeThrough)\)", "$1" + Color.StrikeThrough);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((StrikeThrough)\)", "$1" + Color.StrikeThrough);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((BoldOff)\)", "$1" + Color.BoldOff);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((BoldOff)\)", "$1" + Color.BoldOff);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((ItalicsOff)\)", "$1" + Color.ItalicsOff);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((ItalicsOff)\)", "$1" + Color.ItalicsOff);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((UnderlineOff)\)", "$1" + Color.UnderlineOff);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((UnderlineOff)\)", "$1" + Color.UnderlineOff);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((InverseOff)\)", "$1" + Color.InverseOff);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((InverseOff)\)", "$1" + Color.InverseOff);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((StrikeThroughOff)\)", "$1" + Color.StrikeThroughOff);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((StrikeThroughOff)\)", "$1" + Color.StrikeThroughOff);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((Black)\)", "$1" + Color.Black);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((Black)\)", "$1" + Color.Black);

            //stringToInject = Regex.Replace(stringToInject, @"^color\(Red\)", "$1" + Color.Red);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\(Red\)", "$1" + Color.Red);

            StringBuilder sb = new StringBuilder(stringToInject);
            sb = sb.Replace("color(Red)", Color.Red);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((Green)\)", "$1" + Color.Green);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((Green)\)", "$1" + Color.Green);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((Yellow)\)", "$1" + Color.Yellow);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((Yellow)\)", "$1" + Color.Yellow);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((Blue)\)", "$1" + Color.Blue);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((Blue)\)", "$1" + Color.Blue);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((Magenta)\)", "$1" + Color.Magenta);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((Magenta)\)", "$1" + Color.Magenta);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((Cyan)\)", "$1" + Color.Cyan);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((Cyan)\)", "$1" + Color.Cyan);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((White)\)", "$1" + Color.White);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((White)\)", "$1" + Color.White);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((Default)\)", "$1" + Color.Default);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((Default)\)", "$1" + Color.Default);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((BackgroundBlack)\)", "$1" + Color.BackgroundBlack);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((BackgroundBlack)\)", "$1" + Color.BackgroundBlack);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((BackgroundRed)\)", "$1" + Color.BackgroundRed);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((BackgroundRed)\)", "$1" + Color.BackgroundRed);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((BackgroundGreen)\)", "$1" + Color.BackgroundGreen);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((BackgroundGreen)\)", "$1" + Color.BackgroundGreen);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((BackgroundYellow)\)", "$1" + Color.BackgroundYellow);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((BackgroundYellow)\)", "$1" + Color.BackgroundYellow);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((BackgroundBlue)\)", "$1" + Color.BackgroundBlue);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((BackgroundBlue)\)", "$1" + Color.BackgroundBlue);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((BackgroundMagenta)\)", "$1" + Color.BackgroundMagenta);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((BackgroundMagenta)\)", "$1" + Color.BackgroundMagenta);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((BackgroundCyan)\)", "$1" + Color.BackgroundCyan);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((BackgroundCyan)\)", "$1" + Color.BackgroundCyan);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((BackgroundWhite)\)", "$1" + Color.BackgroundWhite);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((BackgroundWhite)\)", "$1" + Color.BackgroundWhite);

            //stringToInject = Regex.Replace(stringToInject, @"^color\((BackgroundDefault)\)", "$1" + Color.BackgroundDefault);
            //stringToInject = Regex.Replace(stringToInject, @"([^/])color\((BackgroundDefault)\)", "$1" + Color.BackgroundDefault);

            return sb.ToString();
        }
    }
}
